<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let students = [];
			function init(){
				let xhr = new XMLHttpRequest();
				xhr.open("GET","stus.xml",false)
				xhr.send()
				let xmldata = xhr.responseXML
				students = xmldata.querySelectorAll("student")
				document.getElementById("num").value = students[0].getAttribute("sno")
				document.getElementById("sname").value = students[0].getAttribute("sname")
			}
		
		</script>
	</head>
	<body onload="init()">
		学生：<input type="text" id="num">
		<br>
		姓名：<input type="text" id="sname">
		<button type="button" onclick="next()">下一个</button>
		<script type="text/javascript">
			let n = 0;
			document.querySelector("button").onclick = function(){
				n++
				if(n > students.length-1){
					n = 0
				}
				document.getElementById("num").value = students[n].getAttribute("sno")
				document.getElementById("sname").value = students[n].getAttribute("sname")
			}
		</script>
	</body>
</html>
